module.exports = function ($scope, $resource,guide_code,flag, $state, $http, FileUploader, toaster,$modalInstance) {
  var guide_code = flag ? {'flag': true} : guide_code;
  console.log('----------utillllllllllllllllllllll------------')
  console.log(guide_code)
  $scope.flag = 0;
  if(guide_code){
    $scope.flag = 1
      $resource('/api/as/ggc/tourgroupafter/getGuideDetailByCode', {}, {}).save({'guide_code':guide_code},function (res) {
        $scope.info = res.data;
        console.log($scope.info);
      });
  }
  $scope.save = function(){
    $resource('/api/as/ggc/tourgroupafter/createGuide', {}, {}).save($scope.info,function (res) {
      if(res.errcode !=0) {
        toaster.error({ title: "提示", body: res.errmsg });
      }
      else{
        toaster.success({title: "提示", body: "创建成功！"});
        console.log(res);
        $modalInstance.close();
      }
    });
  }

  $scope.update = function (){
    $resource('/api/as/ggc/tourgroupafter/updateGuide', {}, {}).save($scope.info,function (res) {
      if(res.errcode !=0) {
        toaster.error({ title: "提示", body: res.errmsg });
      }
      else{
        toaster.success({title: "提示", body: "修改成功！"});
        console.log(res);
        $modalInstance.close();
      }
    });
  }


  

    }